﻿using Autofac.Extensions.DependencyInjection;
using Autofac;
using DFGJ.WMS_PDA.WebAPI.Utility;
using DFGK.WMS.Common.JWT;
using System.IdentityModel.Tokens.Jwt;

namespace DFGJ.WMS_PDA.WebAPI.Extensions
{  
    /// <summary>
    /// Atuofac扩展
    /// </summary>
    public static class AutofacExtend
    {
        /// <summary>
        /// Autofac注入
        /// </summary>
        /// <param name="builder"></param>
        public static void AddAutofacSetUp(this WebApplicationBuilder builder)
        {
            builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()).ConfigureContainer<ContainerBuilder>(builder =>
            {
                builder.RegisterModule(new AutoFacManage());

                builder.RegisterType<JwtSecurityTokenHandler>().SingleInstance();
                builder.RegisterType<TokenHelper>().SingleInstance();
            });

        }
    }
}
